#include <cstdio>
#include <map>
using namespace std;

struct Stick {
    Stick() {}
    bool rem;
    int pos1, pos2;
    int conn1, conn2;
};

Stick S[13];

int transfer(int i1, int i2, int i3, int i4) {
    return i1 * 64 + i2 * 16 + i3 * 4 + i4 * 1;
}

void initialize() {
    /*
     J Q
    8 9 T
     6 7
    3 4 5
     1 2
    */
    S[1].pos1 = transfer(1, 0, 1, 1);
    S[1].pos2 = transfer(1, 1, 1, 0);
    S[1].conn1 = 1, S[1].conn2 = 2;

    S[2].pos1 = transfer(2, 0, 2, 1);
    S[2].pos2 = transfer(2, 1, 2, 0);
    S[2].conn1 = 2, S[2].conn2 = 3;

    S[3].pos1 = transfer(0, 1, 1, 1);
    S[3].pos2 = transfer(1, 1, 0, 1);
    S[3].conn1 = 1, S[3].conn2 = 4;

    S[4].pos1 = transfer(2, 1, 1, 1);
    S[4].pos2 = transfer(1, 1, 2, 1);
    S[4].conn1 = 2, S[4].conn2 = 5;

    S[5].pos1 = transfer(2, 1, 3, 1);
    S[5].pos2 = transfer(3, 1, 2, 1);
    S[5].conn1 = 3, S[5].conn2 = 6;

    S[6].pos1 = transfer(1, 2, 1, 1);
    S[6].pos2 = transfer(1, 1, 1, 2);
    S[6].conn1 = 4, S[6].conn2 = 5;

    S[7].pos1 = transfer(2, 1, 2, 2);
    S[7].pos2 = transfer(2, 2, 2, 1);
    S[7].conn1 = 5, S[7].conn2 = 6;

    S[8].pos1 = transfer(0, 2, 1, 2);
    S[8].pos2 = transfer(1, 2, 0, 2);
    S[8].conn1 = 4, S[8].conn2 = 7;

    S[9].pos1 = transfer(1, 2, 2, 2);
    S[9].pos2 = transfer(2, 2, 1, 2);
    S[9].conn1 = 5, S[9].conn2 = 8;

    S[10].pos1 = transfer(2, 2, 3, 2);
    S[10].pos2 = transfer(3, 2, 2, 2);
    S[10].conn1 = 6, S[10].conn2 = 9;

    S[11].pos1 = transfer(1, 2, 1, 3);
    S[11].pos2 = transfer(1, 3, 1, 2);
    S[11].conn1 = 7, S[11].conn2 = 8;

    S[12].pos1 = transfer(2, 2, 2, 3);
    S[12].pos2 = transfer(2, 3, 2, 2);
    S[12].conn1 = 8, S[12].conn2 = 9;
}

int s, c, r;
int MAP[10][10];
int MEM[10][10];
const char* str[3] = {"SOHA", "TARA", "No Cheese!"};
const int num_of_sticks = 12;
const int row_of_squares = 9;
const int CLOSED = 0, OPENED = 1;
const int WIN = 1, LOSE = 0;
const int NO_CHEESE = 2, SOHA = 0, TARA = 1;
const int NOT_VISITED = 0, VISITED = 1;

struct Elem {
    int M[row_of_squares + 1][row_of_squares + 1];
    int turn;
    int winner;

    void copy(const int (*M)[row_of_squares + 1]) {
        for(int i = 0; i <= row_of_squares; ++i) {
            for(int j = 0; j <= row_of_squares; ++j) {
                this->M[i][j] = M[i][j];
            }
        }
    }
};

struct Compare {
    bool operator () (const Elem& e1, const Elem& e2) const {
        for(int i = 0; i <= row_of_squares; ++i) {
            for(int j = 0; j <= row_of_squares; ++j) {
                if(e1.M[i][j] > e2.M[i][j]) {
                    return true;
                } else if(e1.M[i][j] < e2.M[i][j]) {
                    return false;
                }
            }
        }
        return false;
    }
};

map< Elem, int, Compare > history;

void clear() {
    for(int i = 1; i <= num_of_sticks; ++i) {
        S[i].rem = false;
    }
    for(int i = 1; i <= row_of_squares; ++i) {
        for(int j = 1; j <= row_of_squares; ++j) {
            MAP[i][j] = CLOSED;
        }
    }
    history.clear();
}

void input() {
    scanf("%d%d%d", &s, &c, &r);
    int i1, i2, i3, i4;
    while(r--) {
        scanf("%d%d%d%d", &i1, &i2, &i3, &i4);
        int t = transfer(i1, i2, i3, i4);
        for(int i = 1; i <= num_of_sticks; ++i) {
            if(S[i].pos1 == t || S[i].pos2 == t) {
                S[i].rem = true;
                MAP[ S[i].conn1 ][ S[i].conn2 ] = MAP[ S[i].conn2 ][ S[i].conn1 ] = OPENED;
                break;
            }
        }
    }
}

bool run(int x, int* USED) {
    if(x == c) {
        return true;
    } else {
        for(int i = 1; i <= row_of_squares; ++i) {
            if(MAP[x][i] == OPENED && USED[i] == NOT_VISITED) {
                USED[i] = VISITED;
                if(run(i, USED)) {
                    USED[i] = NOT_VISITED;
                    return true;
                }
                USED[i] = NOT_VISITED;
            }
        }
    }
    return false;
}

bool mouse_run() {
    int USED[row_of_squares + 1] = {NOT_VISITED};
    if(run(s, USED)) {
        return true;
    }
    return false;
}

int sim(int p) {
    Elem old_e;
    old_e.copy(MAP);
    map< Elem, int, Compare > :: const_iterator it = history.find(old_e);
    if(it != history.end()) {
        int turn = (it->first).turn;
        int winner = (it->first).winner;
        if(turn == p) {
            return winner;
        }
        return 1 - winner;
    }
    int next_p = 1 - p;
    for(int i = 1; i <= num_of_sticks; ++i) {
        if(S[i].rem == false) {
            S[i].rem = true;
            MAP[ S[i].conn1 ][ S[i].conn2 ] = MAP[ S[i].conn2 ][ S[i].conn1 ] = OPENED;
            if(!mouse_run()) {
                int winner = sim(next_p);
                S[i].rem = false;
                MAP[ S[i].conn1 ][ S[i].conn2 ] = MAP[ S[i].conn2 ][ S[i].conn1 ] = CLOSED;
                if(winner == p) {
                    old_e.turn = p;
                    old_e.winner = p;
                    history.insert(pair< Elem, int >(old_e, VISITED));
                    return p;
                }
            } else {
                S[i].rem = false;
                MAP[ S[i].conn1 ][ S[i].conn2 ] = MAP[ S[i].conn2 ][ S[i].conn1 ] = CLOSED;
                old_e.turn = p;
                old_e.winner = p;
                history.insert(pair< Elem, int >(old_e, VISITED));
                return p;
            }
        }
    }
    old_e.turn = p;
    old_e.winner = next_p;
    history.insert(pair< Elem, int >(old_e, VISITED));
    return next_p;
}

int cal() {
    if(mouse_run()) {
        return NO_CHEESE;
    }
    return sim(SOHA);
}

void output(int cases) {
    printf("Case %d: ", cases);
    puts(str[ cal() ]);
}

int main() {
    initialize();
    int cases;
    scanf("%d", &cases);
    for(int i = 1; i <= cases; ++i) {
        clear();
        input();
        output(i);
    }
    return 0;
}
